import request from '@/utils/request'
import download from '@/utils/downFiles'
import * as proxy from '@/constants/proxy'

//部门单位字典数据
export function getUnitData() {
  return request({
    url: proxy.CHECC_API_CMS + '/kjsl/common/getOrgsByLoginUser',
    method: 'get',
  })
}

//部门人员字典数据
export function getPersonnelData(data) {
  return request({
    url: proxy.CHECC_API_CMS + '/kjsl/common/getUsers',
    method: 'post',
    data,
  })
}

//项目列表
// export function getprojectList(data) {
//     return request({
//         url: proxy.CHECC_API_CMS + '/xmzx/projectManagement/listPage',
//         method: 'get',
//         data
//     })
// }
export function getprojectList() {
  return request({
    url: proxy.CHECC_API_CMS + '/xmzx/projectManagement/undertakeunit',
    method: 'post',
  })
}

/**
 * //根据字典代码列表查询全部字典
 * @param data
 * 平台基地建设
 * *研究领域	KJSL_RESEARCH_FIELD
 * *建设方式	KJSL_HPLAT_CONSTRUCTION_METHOD
 * *平台状态	KJSL_PLATFORM_STATUS
 * *成员角色	KJSL_MEMBER_ROLE
 * *文件类型	KJSL_FILE_TYPE
 * *平台级别	KJSL_INNOVATE_PLATFORM_LEVEL
 * *平台类别
 * *建设方式	KJSL_CONSTRUCTION_METHOD
 * *基地级别	KJSL_BASE_LEVEL
 * *平台级别	KJSL_PLATFORM_LEVEL
 * *专业级别	KJSL_PROFESSIONAL_LEVEL
 *
 * 创新人才队伍
 * *团队状态	KJSL_TEAM_STATUS
 * *人才级别	KJSL_TALENT_LEVEL
 * *人才类别	KJSL_TALENT_CATEGORY
 * *获得称号	KJSL_OBTAINING_TITLES
 *
 *
 * 科技成果
 * *简单法律事件	KJSL_SIMPLE_LEGAL_EVENTS
 * *专利类型	KJSL_PATENT_TYPE
 * *附件类型	KJSL_ATTACHMENT_TYPE1
 * *法律状态	KJSL_LEGAL_STATUS
 * *附件类型	KJSL_ATTACHMENT_TYPE
 * *学术著作级别	KJSL_ACADEMIC_WORK_LEVEL
 * *编著属性	KJSL_EDITORIAL_PROPERTIES
 * *企业排名	KJSL_ENTERPRISE_RANKING
 * *论文级别	KJSL_THESIS_LEVEL
 * *语言	KJSL_LANGUAGE
 * *奖励类型	KJSL_REWARD_TYPE
 *
 * 科技奖励
 * *
 *
 * 项目状态：KJSL_PROJECT_STATUS
 * 项目来源：KJSL_PROJECT_SOURCE
 * 基地级别：KJSL_BASE_LEVEL
 * @returns
 */
// /kjsl/common/getDictByCodeList/{codes}
export function getDictionaryList(data: any) {
  return request({
    url: proxy.CHECC_API_CMS + '/dictItem/codelist',
    method: 'post',
    data,
  })
}

export function getDictByCodeList(code: any) {
  return request({
    url: proxy.CHECC_API_CMS + `/kjsl/common/getDictByCodeList/${code}`,
    method: 'get',
  })
}

//角色列表
export function getRoleList() {
  return request({
    url: proxy.CHECC_API_CMS + '/role/list',
    method: 'get',
  })
}

//全部人员
export function getUserAllList() {
  return request({
    url: proxy.CHECC_API_CMS + '/user/getAll',
    method: 'get',
  })
}

//分页查询人员列表
export function getUserList(data: any) {
  return request({
    url: proxy.CHECC_API_CMS + '/user/pageList',
    method: 'post',
    data,
  })
}

//全部机构单位
export function getOrgAllList() {
  return request({
    url: proxy.CHECC_API_CMS + '/org/selectTreeByLoginOrg',
    method: 'get',
  })
}

// export const getOrgAllList = () => {
//   return request({
//     url: proxy.CHECC_API_CMS + '/org/tree',
//     method: 'get'
//   })
// }

//文件下载1
export function downloadByUrl(fileId: any, fileName) {
  return download({
    fileName: fileName,
    url: '/fastDfs/file/download',
    params: {
      fileId
    },
  })
  // const params = {
  //   method:'get',
  //   url: proxy.CHECC_API_CMS + '/fastdfs/file/download',
  //   params:'fileId=' + data.fileId,
  //   fileName: data.fileName
  // }
  // return downloadMethod(params)
}

//文件删除(无效，暂时不用)
export function delectFiles(id: any) {
  return request({
    url: `/fastDfs/file_info/${id}`,
    method: 'delete',
  })
}
